import java.util.ArrayList;
import java.util.Random;

public class DiceBucket
{
    /**
     * Constructor for the DiceBucket
     */
    public DiceBucket()
    {
        // Initializes the random number generator and the current roll
        _generator = new Random();
        _currentRoll = new Die[DICE_LIMIT];
        
        // Fills the current roll with dice
        for (int i = 0; i < DICE_LIMIT; i++)
        {
            _currentRoll[i] = new Die(_generator);
        }
        
        // Rolls all the dice
        rollAll();
    }
    
    
    /**
     * Rolls dice at indices passed in as an array of Die.
     * 
     * @param diceIndex.indexOf(arg0) to be rolled
     * @param random number generator
     * @return currentDice
     */
    public Die[] roll(ArrayList<Integer> diceIndex)
    {   
        // Rolls 
        for (int i = 0; i < diceIndex.size(); i++)
        {
            _currentRoll[diceIndex.get(i)] = new Die(_generator);
        }
        
        return _currentRoll;
    }
    
    /**
     * Rolls all dice.
     */
    public void rollAll()
    {
        // Forms new integer array with all indices to be rolled
        ArrayList<Integer> all = new ArrayList<Integer>();
        for(int i = 0 ; i <= 7 ; i++)
        {
        	all.add(i);
        }
        
        // Calls roll on the entire roll
        _currentRoll = roll(all);
    }
    
    
    /**
     * Returns the current roll of dice
     * 
     * @return currentRoll
     */
    public Die[] getDice()
    {
        return _currentRoll;
    }
    
    
    // Instance variables
    private static Die[] _currentRoll;
    private static Random _generator;
    private final int DICE_LIMIT = 8;
}

